public class Person {
    private String name;
    private int age;

    // Constructor, getters and setters
    public Person(String name, int age) {
        this.name = name;
        this.age = age;
    }

    @Override
    public boolean equals(Object obj) {
        //此处的this表示当前调用此方法的对象
        //若这两个对象的地址相同则返回true
        if (this == obj) {
            return true;
        }
        //判断当前调用方法的对象和obj对象是否是同一个类型
        if (obj == null || this.getClass() != obj.getClass()) {
            return false;
        }
        Person person = (Person) obj;
        //判断这两个对象的属性值是否相同
        return this.age == person.age &&
                (this.name != null ? this.name.equals(person.name) : person.name == null);
    }


}